********************************************************************************
*Project:  	Swiss Trade During the Covid-19 Pandemic: An Early Appraisal	
*Authors:	KB, SL, VP, PW											
*This File: Figure 7b
*Version: 	vFinal						
*Date: 		2020-09-01				
********************************************************************************

********************************************************************************
*1. Weekly Trade Comparison with Previous Years
********************************************************************************

* I. Import and Prepare Data 

import excel "${root}\data\Country_Data_Other\snb_exchange_rates.xlsx", sheet("Exchange Rates") clear

drop in 5
drop in 4
drop in 3 
drop in 2 
drop in 1

drop F

rename A date
rename B chf_euro
rename C chf_usd
rename D chf_jpy
rename E chf_gbp

drop if date==""

split date, parse("/")
destring date1, gen(month)
destring date2, gen(day)
destring date3, gen(year)
drop date*

gen date=mdy(month, day, year)

format date %tddd.nn.YY
sort date

foreach var in euro usd jpy gbp {
	destring chf_`var', replace
	gen `var'_chf=1/chf_`var'
	
	gen `var'_chf_100t=`var'_chf if date==td(3jan2020)
	gen chf_`var'_100t=chf_`var' if date==td(3jan2020)
	
	egen `var'_chf_100base=mean(`var'_chf_100t)
	egen chf_`var'_100base=mean(chf_`var'_100t)
	
	gen `var'_chf_100=100*`var'_chf/`var'_chf_100base 
	gen chf_`var'_100=100*chf_`var'/chf_`var'_100base 
	
	drop `var'_chf_100base `var'_chf_100t
	drop chf_`var'_100base chf_`var'_100t
}

order date year month day euro_chf usd_chf jpy_chf gbp_chf chf_euro chf_usd chf_jpy chf_gbp
compress

graph twoway 																	///
(line usd_chf_100 date if date>=td(1jan2020) & date<td(1aug2020),  lcolor(gs14) lwidth(medium))		///
(line euro_chf_100 date if date>=td(1jan2020) & date<td(1aug2020),  lcolor(gs10) lwidth(medium))		///
(line jpy_chf_100 date if date>=td(1jan2020) & date<td(1aug2020), lpattern(shortdash)  lcolor(gs8) lwidth(medium))		///
(line gbp_chf_100 date if date>=td(1jan2020) & date<td(1aug2020), lpattern(dash) lcolor(gs2) lwidth(medium)),	///
ytitle("Foreign Currency Units per CHF (3.1.2020=100)")  yscale(range (95 115)) ///
ylabel(95(5)115,grid) xlabel(#8)  xtitle("")									///
tline(16mar2020, lcolor(maroon) lwidth(medium)) 								///	
ttext(95.4 15mar2020 "Swiss Lockdown (16.3.2020)", place(e) size(small) orient(horizontal) color(maroon))  ///
legend(order (3 "CHF/JPY" 2 "CHF/EURO" 4 "CHF/GBP" 1 "CHF/USD") cols(2))										///
scheme(s1color) 
graph export "${root}\figures\FIG7b_exchange_rate_2020.png", replace
graph export "${root}\figures\FIG7b_exchange_rate_2020.pdf", replace
